package es.onlysolutions.gs.web.validator;

import es.onlysolutions.gs.web.commandBean.UploadVideoBean;
import es.onlysolutions.arq.core.mvc.command.AbstractCommandBean;
import org.springframework.validation.Errors;

/**
 * Validator to the upload of a video.
 */
public class UploadVideoValidator extends GSValidator
{

    public boolean supports(Class aClass)
    {
        return UploadVideoBean.class == aClass;
    }

    protected void validateForm(AbstractCommandBean abstractCommandBean, Errors errors)
    {
        UploadVideoBean bean = (UploadVideoBean) abstractCommandBean;

        boolean title = rejectIfEmptyOrWhitespace(errors, "videoTitle", "fieldRequired",
                new String[]{"Video Title"}, "The field {0} is required");

        boolean content = rejectIfEmptyOrWhiteEspaceOrLength(errors, bean.getVideoContent(),"Video Content",
                "videoContent", 250);

        boolean file = rejectIfEmptyOrWhitespace(errors, "videoFile", "fieldRequired",
                new String[]{"Video File"}, "The field {0} is required");

        boolean videoKeyWords = rejectIfEmptyOrWhitespace(errors, "videoKeyWords", "fieldRequired",
                new String[]{"Video KeyWords"}, "The field {0} is required");

        boolean videoCategoryContent = rejectIfEmptyOrWhitespace(errors, "videoCategoryContent", "fieldRequired",
                new String[]{"Category Content"}, "The field {0} is required");

        boolean videoCategoryLabel = rejectIfEmptyOrWhitespace(errors, "videoCategoryLabel", "fieldRequired",
                new String[]{"Category Label"}, "The field {0} is required");

        boolean youTubeUsername = rejectIfEmptyOrWhitespace(errors, "youTubeUsername", "fieldRequired",
                new String[]{"You Tube Usernamey"}, "The field {0} is required");

        boolean youTubePassw = rejectIfEmptyOrWhitespace(errors, "youTubePassword", "fieldRequired",
                new String[]{"You Tube Password"}, "The field {0} is required");



    }
}
